package com.example.leoss.Duquzifu;

import android.content.Context;

public class Data implements Comparable<Data>{


    int id;
     String name;
    String phome;
    Context context;
    String qq;
    String weixing;
    String address;
    String majar;
    String sex;
    int icon;
    private String pinyin; // 姓名对应的拼音
    private String firstLetter; // 拼音的首字母

    public Data(int id, String name, String phome, Context context, String qq, String weixing, String address, String majar, String sex, int icon) {
        this.id=id;
        this.name = name;
        this.phome = phome;
        this.context = context;
        this.qq = qq;
        this.weixing = weixing;
        this.address = address;
        this.majar = majar;
        this.sex = sex;
        this.pinyin = pinyin;
        this.firstLetter = firstLetter;
        this.icon=icon;


            pinyin = Cn2Spell.getPinYin(name); // 根据姓名获取拼音
        firstLetter = pinyin.substring(0, 1).toUpperCase(); //获取拼音首字母并转成大写

    if (!firstLetter.matches("[A-Z]"))
    { // 如果不在A-Z中则默认为“#”
        firstLetter = "#";
    }
    }

    //    public  Data (int img,String name,String phome,Context context){
//        this.img=img;
//        this.context=context;
//        this.name=name;
//        this.phome=phome;
//
//
//    pinyin = Cn2Spell.getPinYin(name); // 根据姓名获取拼音
//
//
//        firstLetter = pinyin.substring(0, 1).toUpperCase(); //获取拼音首字母并转成大写
//
//    if (!firstLetter.matches("[A-Z]"))
//    { // 如果不在A-Z中则默认为“#”
//        firstLetter = "#";
//    }
//
//
//
//    }

    @Override
    public int compareTo(Data another)
    {
        if (firstLetter.equals("#") && !another.getFirstLetter().equals("#")) {
            return 1;
        } else if (!firstLetter.equals("#") && another.getFirstLetter().equals("#")){
            return -1;
        } else {
            return pinyin.compareToIgnoreCase(another.getPinyin());
        }
    }

    public int getIcon() {
        return icon;
    }

    public void setIcon(int icon) {
        this.icon = icon;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public String getPhome() {
        return phome;
    }

    public Context getContext() {
        return context;
    }

    public String getQq() {
        return qq;
    }

    public String getWeixing() {
        return weixing;
    }

    public String getAddress() {
        return address;
    }

    public String getMajar() {
        return majar;
    }

    public String getSex() {
        return sex;
    }

    public String getPinyin() {
        return pinyin;
    }

    public String getFirstLetter() {
        return firstLetter;
    }


    public void setName(String name) {
        this.name = name;
    }

    public void setPhome(String phome) {
        this.phome = phome;
    }

    public void setContext(Context context) {
        this.context = context;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    public void setWeixing(String weixing) {
        this.weixing = weixing;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public void setMajar(String majar) {
        this.majar = majar;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public void setPinyin(String pinyin) {
        this.pinyin = pinyin;
    }

    public void setFirstLetter(String firstLetter) {
        this.firstLetter = firstLetter;
    }


//    public int getImg() {
//        return img;
//    }
//
//    public String  getPinyin() {
//        return pinyin;
//    }
//    public String getFirstLetter() { return firstLetter; }
//    public String getName() {
//        return name;
//    }
//
//    public void setName(String name) {
//        this.name = name;
//    }
//
//    public String getPhome() {
//        return phome;
//    }
//
//    public void setPhome(String phome) {
//        this.phome = phome;
//    }
//    public void setFirstLetter(String firstLetter) {
//        this.firstLetter = firstLetter;
//    }



}
